/*
 * @Descripttion:
 * @version:
 * @Author: sueRimn
 * @Date: 2022-04-25 14:39:53
 * @LastEditors: sueRimn
 * @LastEditTime: 2022-12-30 11:26:53
 */
export default {
  state: {
    navTree: [], // 导航菜单树
    orderNavTree: [], // 导航菜单树
    currentRoute: {},
    rbNavData: {
      data: [],
      name: ""
    } //专题分析日报菜单数据
  },
  getters: {
    navTreeList(state) {
      return state.navTree;
    },
    getOrderNavTree(state) {
      return state.orderNavTree;
    },
    menuChilds: state => (navTree, name) => {
      return navTree[0].children.filter(nav => {
        return nav.meta.title == name;
      });
    }
    // menuChilds: state => (navTree, name) => {
    //   var list;
    //   navTree[0].children.forEach(nav => {
    //     if (nav.name == name) {
    //       list = nav;
    //     } else if (nav.children) {
    //       list = nav.children.filter(item => {
    //         return item.meta.title == name;
    //       });
    //     }
    //   });
    //   return list;
    // }
  },
  mutations: {
    setNavTree(state, navTree) {
      // 设置导航菜单树
      state.navTree = navTree;
    },
    setCurrentRoute(state, route) {
      state.currentRoute = route;
    },
    setrbNavData(state, route) {
      state.rbNavData = route;
    },
    setOrderNavTree(state, navTree) {
      state.orderNavTree = navTree;
    }
  },
  actions: {}
};
